package com.archive.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.archive.common.annotation.Log;
import com.archive.common.core.controller.BaseController;
import com.archive.common.core.domain.AjaxResult;
import com.archive.common.enums.BusinessType;
import com.archive.manage.domain.SkillCertificate;
import com.archive.manage.service.ISkillCertificateService;
import com.archive.common.utils.poi.ExcelUtil;
import com.archive.common.core.page.TableDataInfo;

/**
 * 简历技能证书信息Controller
 * 
 * @author marioduan
 * @date 2025-05-02
 */
@RestController
@RequestMapping("/manage/certificate")
public class SkillCertificateController extends BaseController
{
    @Autowired
    private ISkillCertificateService skillCertificateService;

    /**
     * 查询简历技能证书信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:certificate:list')")
    @GetMapping("/list")
    public TableDataInfo list(SkillCertificate skillCertificate)
    {
        startPage();
        List<SkillCertificate> list = skillCertificateService.selectSkillCertificateList(skillCertificate);
        return getDataTable(list);
    }

    /**
     * 导出简历技能证书信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:certificate:export')")
    @Log(title = "简历技能证书信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SkillCertificate skillCertificate)
    {
        List<SkillCertificate> list = skillCertificateService.selectSkillCertificateList(skillCertificate);
        ExcelUtil<SkillCertificate> util = new ExcelUtil<SkillCertificate>(SkillCertificate.class);
        util.exportExcel(response, list, "简历技能证书信息数据");
    }

    /**
     * 获取简历技能证书信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:certificate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(skillCertificateService.selectSkillCertificateById(id));
    }

    /**
     * 根据学号获取简历技能证书名称
     */
    @PreAuthorize("@ss.hasPermi('manage:certificate:query')")
    @GetMapping(value = "/resume/{id}")
    public AjaxResult getInfoByStudentId(@PathVariable("id") String id)
    {
        return success(skillCertificateService.selectSkillCertificateByStudentId(id));
    }
    /**
     * 新增简历技能证书信息
     */
//    @PreAuthorize("@ss.hasPermi('manage:certificate:add')")
//    @Log(title = "简历技能证书信息", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody SkillCertificate skillCertificate)
//    {
//        return toAjax(skillCertificateService.insertSkillCertificate(skillCertificate));
//    }

    /**
     * 修改简历技能证书信息
     */
    @PreAuthorize("@ss.hasPermi('manage:certificate:edit')")
    @Log(title = "简历技能证书信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SkillCertificate skillCertificate)
    {
        return toAjax(skillCertificateService.updateSkillCertificate(skillCertificate));
    }

    /**
     * 删除简历技能证书信息
     */
    @PreAuthorize("@ss.hasPermi('manage:certificate:remove')")
    @Log(title = "简历技能证书信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(skillCertificateService.deleteSkillCertificateByIds(ids));
    }
}
